package compCreateWord;

import java.util.Random;
import wordChecker.IWordChecker;

public class CreateStandardWord implements ICreateWord {

	@Override
	public String createWord( IWordChecker wordChecker, String givenString ) {
		
		String stringToReturn = "";
		Random rnd = new Random( System.currentTimeMillis() );
		
		while( !wordChecker.isCorrectWord(stringToReturn) ){
			
			// pierwsza litera - 70% szans ze powieli dobra litere :
			if( givenString != "" && rnd.nextInt(10) < 7 )
				stringToReturn += Character.toString( givenString.charAt( givenString.length()-1 ) ) ;
			
			// druga litera i dalsze:
			for( int i = 0; i < rnd.nextInt(6)+6 ; i++ ){
				stringToReturn += Integer.toString( rnd.nextInt(10) ) ;
			}
		}
		
		return stringToReturn;
	}

}
